
using Orchard.ContentManagement.MetaData;

using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

namespace Wicresoft.Movies {
    public class Migrations : DataMigrationImpl {

        public int Create() {

            ContentDefinitionManager.AlterTypeDefinition("Movie", builder => builder.WithPart("CommonPart")
                .WithPart("Title")
                .WithPart("AutoroutePart"));

            ContentDefinitionManager.AlterTypeDefinition("Movie", builder => builder.WithPart("BodyPart")
               .Creatable()
               .Draftable());

            ContentDefinitionManager.AlterTypeDefinition("Movie", builder => builder
           .WithPart("Title")
           .WithPart("AutoroutePart"));

            ContentDefinitionManager.AlterTypeDefinition("Movie", builder => builder
                   .WithPart("BodyPart", partbilder =>
                      partbilder.WithSetting("BodyTypePartSettings.Flavor", "text"))
                   .WithPart("BodyPart", partbuilder =>
                       partbuilder
                       .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
                               .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
                               .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Movie Title', Pattern: 'movies/{Content.Slug}', Description: 'films/film-title'}]")
                               .WithSetting("AutorouteSettings.DefaultPatternIndex", "0")));

            SchemaBuilder.CreateTable("MoviePartRecord", table =>
                                                      table.ContentPartRecord()
                                                          // .Column<string>("IBDB_ID")
                                                           .Column<int>("YearReleased")
                                                           .Column<string>("Rating", col => col.WithLength(4)));
            ContentDefinitionManager.AlterTypeDefinition("Movie", builder => builder
                .WithPart("MoviePart"));


            return 1;
        }

        //public int UpdateFrom1() {

           
        //    return 2;
        //}

        //public int UpdateFrom2()
        //{
          
        //    return 3;
        //}

        //public int UpdateFrom3()
        //{
           
        //    return 4;
        //}

        //public int UpdateFrom4() {
         

        //    return 5;
        //}

      
    }
}